{{include file="public/header" /}}
<style>
    *{ margin:0; padding:0; list-style:none; text-decoration:none;}
    .wraper{ width:100%; padding-bottom:20px }
    .nav{ position:relative; width:100%; height:40px; background:#eee; overflow:hidden}
    .nav-item{ position:relative; float:left; width:160px; height:40px; line-height:40px; text-align:center; font-size:14px; z-index:1}
    .nav-item a{ display:block; height:40px; color:#111;}
    .nav-item a:hover{ color:#fff}
    .move-bg{ display:none;position:absolute;left:0;top:0; width:160px; height:40px; background:#4386fb; z-index:0}
    .bg a{background:#4386fb;color:#fff;}
</style>


<!-- right content start  -->
<div class="content-right">
    <div class="content">
        <!-- form start -->
        <form  class="am-form form-validation form-search" method="post" action="{{:MyUrl('admin/goods/index')}}" request-type="form">
            <div class="thin">
                <div class="am-input-group am-input-group-sm am-fl so">
                    <input type="text" autocomplete="off" name="keywords" class="am-radius" placeholder="标题" value="{{if !empty($params.keywords)}}{{$params.keywords}}{{/if}}" />
                    <span class="am-input-group-btn">
                        <button class="am-btn am-btn-default am-radius" type="submit" data-am-loading="{spinner:'circle-o-notch', loadingText:'搜索中...'}">搜索</button>
                    </span>
                </div>
                <label class="am-fl thin_sub more-submit">
                    更多筛选条件
                    {{if isset($params['is_more']) and $params['is_more'] eq 1}}
                    <input type="checkbox" name="is_more" value="1" id="is_more" checked />
                    <i class="am-icon-angle-up"></i>
                    {{else /}}
                    <input type="checkbox" name="is_more" value="1" id="is_more" />
                    <i class="am-icon-angle-down"></i>
                    {{/if}}
                </label>
            </div>
            <table class="so-list more-where {{if !isset($params['is_more'])}}none{{/if}}">
                <tbody>
                    <tr>
                        <td>
                            <span>分类：</span>
                            <select class="am-radius chosen-select" name="category_id" data-placeholder="商品分类...">
                                <option value="0">商品分类...</option>
                                {{if !empty($goods_category_list)}}
                                {{foreach $goods_category_list as $v}}
                                <option value="{{$v.id}}" {{if !empty($params['category_id']) and $v['id'] eq $params['category_id']}}selected{{/if}}>一级 - {{$v.name}}</option>
                                {{if !empty($v['items'])}}
                                {{foreach $v.items as $vs}}
                                <option style="padding-left: 30px;" value="{{$vs.id}}" {{if !empty($params['category_id']) and $vs['id'] eq $params['category_id']}}selected{{/if}}>二级 - {{$vs.name}}</option>
                                {{if !empty($vs['items'])}}
                                {{foreach $vs.items as $vss}}
                                <option style="padding-left: 60px;" value="{{$vss.id}}" {{if !empty($params['category_id']) and $vss['id'] eq $params['category_id']}}selected{{/if}}>三级 - {{$vss.name}}</option>
                                {{/foreach}}
                                {{/if}}
                                {{/foreach}}
                                {{/if}}
                                {{/foreach}}
                                {{/if}}
                            </select>
                        </td>
                        <td>
                            <span>作者：</span>
                            <input type="text"  style="width:217px"    name="author" value="{{if !empty($params.author)}}{{$params.author}}{{/if}}"  />
                        </td>

                    </tr>
                    <tr>

                        <td>
                            <span>货架号：</span>
                            <input type="text"  style="width:217px" name="shelf_number"  value="{{if !empty($params.shelf_number)}}{{$params.shelf_number}}{{/if}}" />
                        </td>
                        <td>
                            <span>品相：</span>
                           
                              <select name="quality" class="chosen-select" data-placeholder="品相...">
                                <option value="">请选择...</option>
                                {{foreach $quality as $k=>$v}}
                                <option value="{{$v}}" {{if isset($params['quality']) and $params['quality'] eq $k}}selected{{/if}}>{{$v}}</option>
                                {{/foreach}}
                            </select>
                        </td>
                    </tr>
                    <tr>

                        <td>
                            <span>售价：</span>
                            <input type="text"  style="width:100px" name="price" value="{{if !empty($params.price)}}{{$params.price}}{{/if}}" />—
                            <input type="text"  style="width:100px" name="price1" value="{{if !empty($params.price1)}}{{$params.price1}}{{/if}}" />
                        </td>
                        <td>
                            <span>isbn：</span>
                            <input type="text"  style="width:217px"    name="isbn"  value="{{if !empty($params.isbn)}}{{$params.isbn}}{{/if}}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span>状态：</span>
                            <select name="is_shelves" class="chosen-select" data-placeholder="上下架...">
                                <option value="-1">上下架...</option>
                                {{foreach $common_is_shelves_list as $v}}
                                <option value="{{$v.id}}" {{if isset($params['is_shelves']) and $params['is_shelves'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option>
                                {{/foreach}}
                            </select>
                        </td>
                        <td>
                            <span>推荐：</span>
                            <select name="is_home_recommended" class="chosen-select" data-placeholder="首页推荐...">
                                <option value="-1">首页推荐...</option>
                                {{foreach $common_is_text_list as $v}}
                                     <option value="{{$v.id}}" {{if isset($params['is_home_recommended']) and $params['is_home_recommended'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option>
                                {{/foreach}}
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="time">
                            <span>时间：</span>
                            <span>
                                <input type="text" autocomplete="off" name="time_start" class="am-form-field am-input-sm am-radius Wdate" placeholder="起始时间" value="{{if !empty($params.time_start)}}{{$params.time_start}}{{/if}}" data-validation-message="日期格式有误" onclick="WdatePicker({firstDayOfWeek: 1, dateFmt: 'yyyy-MM-dd'})" autocomplete="off" /><i class="am-icon-calendar"></i>
                            </span>
                            <em class="text-grey">~</em>
                            <span>
                                <input type="text" autocomplete="off" name="time_end" class="am-form-field am-input-sm am-radius Wdate" placeholder="结束时间" value="{{if !empty($params.time_end)}}{{$params.time_end}}{{/if}}" pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2}$" data-validation-message="日期格式有误" onclick="WdatePicker({firstDayOfWeek: 1, dateFmt: 'yyyy-MM-dd'})" autocomplete="off" /><i class="am-icon-calendar"></i>
                            </span>
                        </td>
                        <td>
                            <button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example" data-am-loading="{spinner:'circle-o-notch', loadingText:'搜索中...'}">搜索</button>
                            <a href="{{:MyUrl('admin/goods/index')}}" class="am-btn am-btn-warning am-radius am-btn-sm reset-submit">清除条件</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
        <!-- form end -->
       
        <!-- operation start -->
        <div class="am-g m-t-15">
            <a href="{{:MyUrl('admin/goods/saveinfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus"> 新增</a>
                 <a href="javascript:void();"   data-am-modal="{target: '#bookslist'}"  class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus"> 添加到书单</a>
        </div>
        <div style="" class="am-popup am-radius" id="bookslist">
         <div class="am-popup-inner">
                                <div class="am-popup-hd">
                                    <h4 class="am-popup-title">选择书单</h4>
                                    <span data-am-modal-close
                                          class="am-close">&times;</span>
                                </div>
                                <div class="am-popup-bd">
                                    <dl class="dl-content">
                                        <dt>书单</dt>
                                        <dd> 
                                               <div style="display:inline-block;width:80%" >
                                                   <select id="books_id" name="books" class="am-radius chosen-select"   data-placeholder="可选择..." data-validation-message="请选择品相信息" required>
                                                       <option value="">可选择...</option>
                                                        {{if !empty($books_list) }}
                                                        {{foreach $books_list as $k=>$v}}
                                                            
                                                                 <option style="padding-left: 30px;" value="{{$v['id']}}" >{{$v.title}}</option>

                                                        {{/foreach}}
                                                        {{/if}}
                                                   </select>
                                               </div>
                                        </dd>
                                    </dl>
                                      <dl class="dl-content">
                                        <dt></dt>
                                        <dd> 
                                               <div style="display:inline-block;width:80%" >
                                                    <button  id="remind" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block">添加到书单</button>
                                               </div>
                                        </dd>
                                    </dl>
                                </div>
                            </div>
                        </div>
        </div>
        <!-- operation end -->
 <div class="am-g m-t-15">
            <div class="wraper">    
                <div class="nav">
                    <ul>
                        <li class="nav-item {{if (isset($params['type_num'])  and  $params['type_num'] eq 0) or empty($params['type_num']) }}bg{{/if}}" ><a href='{{:MyUrl('admin/goods/index',['type_num'=>0])}}'>全部商品</a></li>
                        <li class="nav-item {{if !empty($params['type_num'])  and  $params['type_num'] eq 1}}bg{{/if}}"><a href='{{:MyUrl('admin/goods/index',['type_num'=>1])}}'>未售商品</a></li>
                        <li class="nav-item {{if !empty($params['type_num'])  and  $params['type_num'] eq 2}}bg{{/if}}"><a href='{{:MyUrl('admin/goods/index',['type_num'=>2])}}'>最新上架</a></li>
                        <li class="nav-item {{if !empty($params['type_num'])  and  $params['type_num'] eq 3}}bg{{/if}}"><a href='{{:MyUrl('admin/goods/index',['type_num'=>3])}}'>好书推荐</a></li>
                        <li class="nav-item {{if !empty($params['type_num'])  and  $params['type_num'] eq 4}}bg{{/if}}"><a href='{{:MyUrl('admin/goods/index',['type_num'=>4])}}'>珍品孤本</a></li>
                        <li class="nav-item {{if !empty($params['type_num'])  and  $params['type_num'] eq 5}}bg{{/if}}"><a href='{{:MyUrl('admin/goods/index',['type_num'=>5])}}'>下架商品</a></li>
                        <li class="nav-item {{if !empty($params['type_num'])  and  $params['type_num'] eq 6}}bg{{/if}}"><a href='{{:MyUrl('admin/goods/index',['type_num'=>6])}}'>已售商品</a></li>
                    </ul>
                    <!--移动的滑动-->
                    <div class="move-bg"></div>
                    <!--移动的滑动 end-->
                </div>
            </div>
        </div>
        <!-- list start -->
        <table class="am-table am-table-striped am-table-hover am-text-middle m-t-10 goods-list">
            <thead>
                <tr>
                     <th><input type="checkbox" id="CheckAll">&nbsp;全选</th>
                    <th>编号</th>
                    <th>标题名称</th>
                    <th class="am-hide-sm-only">销售价格(元)</th>
                    <th>上下架</th>
                    <th class="am-hide-sm-only">标签</th>
                    <th class="am-hide-sm-only">库存数量</th>
                    <th class="am-hide-sm-only">货架号</th>


                    <th class="am-hide-sm-only">仓库</th>
                    <th class="am-hide-sm-only">操作员</th>
                    <th class="am-hide-sm-only">审核状态</th>

                    <th>更多</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {{if !empty($data_list)}}
                {{foreach $data_list as $v}}
                <tr id="data-list-{{$v.id}}" {{if $v['is_shelves'] eq 0}}class="am-active"{{/if}}>
                       <td><input type="checkbox" class="dh" name='ids[]' value="{{$v.id}}" ></td>
                    <td>{{$v.id}}</td>
                    <td>
                        <a href="{{$v.goods_url}}" target="_blank" title="{{$v.title}}">
                            <img src="{{$v['images']}}" class="am-img-thumbnail am-radius goods-images am-hide-sm-only" />
                        </a>
                        <a href="{{$v.goods_url}}" target="_blank" title="{{$v.title}}" {{if !empty($v['title_color'])}} style="color:{{$v.title_color}};" {{/if}} >{{$v.title}}</a>
                        {{if !empty($v['simple_desc'])}}
                        <p class="cr-red am-hide-md-down">{{$v.simple_desc}}</p>
                        {{/if}}
                    </td>
                    <td class="am-hide-sm-only">
                        {{$v.price}}
                        {{if !empty($v['original_price']) and $v['original_price'] gt 0}}
                        <br /><span class="am-badge am-radius">原价 {{$v.original_price}}</span>
                        {{/if}}
                    </td>
                    <td>
                        <a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_shelves'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:MyUrl('admin/goods/statusshelves')}}" data-id="{{$v.id}}" data-state="{{$v['is_shelves']}}"  data-is-update-status="1"></a>
                    </td>
                    <td class="am-hide-sm-only">
                        <a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_home_recommended'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:MyUrl('admin/goods/statushomerecommended')}}" data-id="{{$v.id}}" data-state="{{$v['is_home_recommended']}}" data-is-update-status="0"></a>首页推荐<br/>
                        <a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['new_upper'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:MyUrl('admin/goods/StatusNewUpper')}}" data-id="{{$v.id}}" data-state="{{$v['new_upper']}}" data-is-update-status="0"></a>最新上架<br/>
                        <a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['recommended_daily'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:MyUrl('admin/goods/StatusRecommendedDaily')}}" data-id="{{$v.id}}" data-state="{{$v['recommended_daily']}}" data-is-update-status="0"></a>每日推荐<br/>
                        <a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['rare_treasures'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:MyUrl('admin/goods/StatusRareTreasures')}}" data-id="{{$v.id}}" data-state="{{$v['rare_treasures']}}" data-is-update-status="0"></a>珍品孤本
                    </td>
                    <td class="am-hide-sm-only">{{$v.inventory}} </td>

                    <td class="am-hide-sm-only">{{$v.shelf_number}}</td>
                    <td class="am-hide-sm-only">{{$v.warehouse_name}}</td>
                    <td class="am-hide-sm-only">{{$v.username}}</td>
                       <td>
                         {{if $v['status'] eq 1}}
                            已审核
                         {{elseif $v['status'] eq 0}}
                            未审核
                         {{elseif $v['status'] eq 2}}
                             已拒绝
                         {{/if}}
                        
                    </td>
                    <td>
                        <span class="am-icon-caret-down c-p" data-am-modal="{target: '#my-popup{{$v.id}}'}"> 查看更多</span>
                        <div class="am-popup am-radius" id="my-popup{{$v.id}}">
                            <div class="am-popup-inner">
                                <div class="am-popup-hd">
                                    <h4 class="am-popup-title">详情内容</h4>
                                    <span data-am-modal-close
                                          class="am-close">&times;</span>
                                </div>
                                <div class="am-popup-bd">
                                    <dl class="dl-content">
                                        <dt>标题名称</dt>
                                        <dd>{{$v.title}}</dd>

                                        <dt>商品简述</dt>
                                        <dd>{{$v.simple_desc}}</dd>

                                        <dt>销售价格(元)</dt>
                                        <dd>
                                            {{$v.price}}
                                            {{if !empty($v['original_price']) and $v['original_price'] gt 0}}
                                            <br /><span class="am-badge am-radius">原价 {{$v.original_price}}</span>
                                            {{/if}}
                                        </dd>

                                        <dt>上下架</dt>
                                        <dd>{{:lang('common_is_shelves_list')[$v['is_shelves']]['name']}}</dd>

                                        <dt>库存数量</dt>
                                        <dd>{{$v.inventory}} </dd>

                                        <dt>品相</dt>
                                        <dd>{{$v.quality}}</dd>

                                        <dt>isbn</dt>
                                        <dd>{{$v.isbn}}</dd>

                                        <dt>商品分类</dt>
                                        <dd>{{$v.category_text}}</dd>

                                        <dt>购买赠送积分</dt>
                                        <dd>{{$v.give_integral}}</dd>

                                        <dt>扣减库存</dt>
                                        <dd>{{:lang('common_is_text_list')[$v['is_deduction_inventory']]['name']}}</dd>

                                        <dt>访问次数</dt>
                                        <dd>{{$v.access_count}}</dd>

                                        <dt>SEO标题</dt>
                                        <dd>{{$v.seo_title}}</dd>

                                        <dt>SEO关键字</dt>
                                        <dd>{{$v.seo_keywords}}</dd>

                                        <dt>SEO描述</dt>
                                        <dd>{{$v.seo_desc}}</dd>

                                        <dt>创建时间</dt>
                                        <dd>{{$v.add_time}}</dd>

                                        <dt>更新时间</dt>
                                        <dd>{{$v.upd_time}}</dd>
                                    </dl>
                                </div>
                            </div>
                        </div>
                    </td>
                  
                    <td class="view-operation">
                        <a href="{{:MyUrl('admin/goods/saveinfo', array_merge($params, ['id'=>$v['id']]))}}">
                            <button class="am-btn am-btn-secondary am-btn-xs am-radius am-icon-edit"> 编辑</button>
                        </a>
                        <button class="am-btn am-btn-danger am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:MyUrl('admin/goods/delete')}}" data-id="{{$v.id}}"> 删除</button>

                        <!-- 商品列表操作钩子 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_admin_goods_list_operation</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_admin_goods_list_operation';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>true, 'id'=>$v['id'], 'data'=>$v]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                    </td>
                   
                </tr>
                {{/foreach}}
                {{/if}}
            </tbody>
        </table>
        {{if empty($data_list)}}
        <div class="table-no"><i class="am-icon-warning"></i> 没有相关数据</div>
        {{/if}}
        <!-- list end -->

        <!-- page start -->
        {{if !empty($data_list)}}
        {{$page_html|raw}}
        {{/if}}
        <!-- page end -->
    </div>
</div>
<!-- right content end  -->

<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

<script type='text/javascript' src="{{$Think.__MY_ROOT_PUBLIC__}}static/admin/default/js/jquery.movebg.js"></script>
<script>
                                        $(function () {
                                            $(".nav").movebg({width: 160/*滑块的大小*/, extra: 40/*额外反弹的距离*/, speed: 300/*滑块移动的速度*/, rebound_speed: 400/*滑块反弹的速度*/});
                                        })


                                        $("#CheckAll").bind("click", function () {
                                            $("input[name='ids[]']").prop("checked", this.checked);
                                        });


                                        $("#remind").click(function () {
                                            if (confirm('确定要批量加入书单?')) {
                                                 
                                                var checks = $("input[name='ids[]']:checked");
                                                if (checks.length == 0) {
                                                    alert('未选中任何项！');
                                                    return false;
                                                }
                                                //将获取的值存入数组
                                                var checkData = new Array();
                                                checks.each(function () {
                                                    checkData.push($(this).val());
                                                });
                                                    
                                                    $.post("{{:MyUrl('admin/Books/addbooksGoods')}} ",
                                                        {goods_ids: checkData.toString(),id:$("#books_id").val()},
                                                        function (result) {
                                                            
                                                            if (result.code === 0) {
                                                                window.location.reload();
                                                            }
                                                            else{
                                                                alert(result.msg);
                                                            }
                                                        });
                                            }
                                      
                                        });

</script>